package com.itheima_05;

import java.io.*;
import java.net.Socket;

public class ClinetTest1 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("E:\\图片\\timg.jpg");
        BufferedInputStream bis = new BufferedInputStream(fis);
        Socket socket = new Socket("127.0.0.1",10086);
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);

        byte[] bys = new byte[1024];
        int len ;
        while ((len = bis.read(bys))!=-1){
            bos.write(bys,0,len);
            bos.flush();

        }
        socket.shutdownOutput();

        InputStream is= socket.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line;
        while ((line = br.readLine())!=null) {
            System.out.print(line);
        }

        //socket.shutdownInput();
       bis.close();
       socket.close();



    }
}
